import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
public class Demo3 {
    //字符的写
    public static void main(String[] args) {
        try(Writer writer=new FileWriter("D:/exercise/hello.txt")) {
            String str="abcdefg";
            writer.write(str);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    //把文件打开的时候，会删除文件之前的内容
    public static void main1(String[] args) {
   try(Writer writer=new FileWriter("D:/exercise/hello.txt")) {
       writer.write("xyz");
   }catch (IOException e){
       e.printStackTrace();
   }
    }
}
